class Solution:
    def canConstruct(self, ransomNote: str, magazine: str) -> bool:
        cnt = [0]*26  # 定义一个列表记录 magazine 中每个字母出现的次数
        for c in magazine:
            cnt[ord(c) - ord('a')] += 1

        for c in ransomNote:
            if cnt[ord(c) - ord('a')] == 0:
                return False
            cnt[ord(c) - ord('a')] -= 1

        return True